package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import lombok.*;

import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class Strategy extends BaseDomain {
    public static final Integer STATE_NOMAL = 0; //正常
    public static final Integer STATE_DISABLE = 1; //禁用
    public static final Integer STATE_COMMEND = 2; //推荐

    private String title;

    private String subTitle;

    private String coverUrl;

    private Integer state;

    private Region place;

    public String getStateName() {
        String str = "正常";
        if (state == STATE_DISABLE) {
            str = "禁用";
        } else if (state == STATE_COMMEND) {
            str = "推荐";
        }
        return str;
    }

    public Object getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        if (place != null) {
            map.put("placeId", place.getId());
        }
        return JSON.toJSONString(map);
    }

}